<template>
  <header :style="{ backgroundColor: curMenu.color }">
    <span @click="gohome">&lt;首页</span>
    {{ curMenu.name }}
  </header>
</template>

<script>
import { mapState, mapMutations } from "vuex";
export default {
  name: "MyHeader",
  computed: {
    ...mapState(["curMenu"]),
  },
  methods: {
    ...mapMutations(["setCurMenu"]),
    gohome() {
      if (this.curMenu.path != "/") {
        this.$router.push("/");
        this.setCurMenu({
          name: "剧集",
          color: "red",
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
header {
  position: fixed;
  top: 0;
  width: 100%;
  height: 1rem;
  line-height: 1rem;
  text-align: center;
  background-color: gray;
  color: white;
  span {
    position: absolute;
    left: 0;
  }
}
</style>